package dao.examinfo;

import java.util.List;

import util.paramvo.MemberPageListParamVO;
import util.paramvo.UnitPageListParamVO;
import vo.ExaminfoVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class ExaminfoDAOImpl implements ExaminfoDAO{

	private SqlMapClient sqlMapClient;

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}

	@Override
	public List<ExaminfoVO> getExaminfos(UnitPageListParamVO param) throws Exception {
		return sqlMapClient.queryForList("examinfo.getExaminfos", param);
	}

	@Override
	public void registerExaminfo(ExaminfoVO param) throws Exception {
		sqlMapClient.insert("examinfo.registerExaminfo", param);
	}

	@Override
	public void updateExaminfo(ExaminfoVO param) throws Exception {
		sqlMapClient.update("examinfo.updateExaminfo", param);
	}

	@Override
	public void deleteExaminfo(int examinfo_no) throws Exception {
		sqlMapClient.update("examinfo.deleteExaminfo", examinfo_no);
	}

	@Override
	public int getExaminfoCount(int majorunit_no) throws Exception {
		return (Integer) sqlMapClient.queryForObject("examinfo.getExaminfoCount", majorunit_no);
	}
	
	@Override
	public int didWriteExaminfo(ExaminfoVO param) throws Exception {
		return (Integer) sqlMapClient.queryForObject("examinfo.didWriteExaminfo", param);
	}

	@Override
	public float getAverageLevel(int majorunit_no) throws Exception {
		return (Float) sqlMapClient.queryForObject("examinfo.getAverageLevel", majorunit_no);
	}

	@Override
	public List<ExaminfoVO> getMyExaminfos(MemberPageListParamVO param) throws Exception {
		return sqlMapClient.queryForList("examinfo.getMyExaminfos", param);
	}

	@Override
	public int getMyExaminfoCount(int member_no) throws Exception {
		return (Integer) sqlMapClient.queryForObject("examinfo.getMyExaminfoCount", member_no);
	}
}
